<html>
<head><meta charset="utf-8"><title>-ffunction-sections · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html">-ffunction-sections</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210883426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210883426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210883426">(Sep 22 2020 at 15:04)</a>:</h4>
<p>OMG, take a look at this: <a href="https://github.com/rust-lang/rust/pull/77051#issuecomment-696779458">https://github.com/rust-lang/rust/pull/77051#issuecomment-696779458</a></p>



<a name="210888353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888353">(Sep 22 2020 at 15:35)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I don't think we want to merge this?</p>



<a name="210888538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888538">(Sep 22 2020 at 15:36)</a>:</h4>
<p>why not?</p>



<a name="210888585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888585">(Sep 22 2020 at 15:36)</a>:</h4>
<p>this is just disabling a feature</p>



<a name="210888597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888597">(Sep 22 2020 at 15:36)</a>:</h4>
<p>to measure the cost of it</p>



<a name="210888677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888677">(Sep 22 2020 at 15:37)</a>:</h4>
<p>we have it because it makes binaries smaller (at the cost of longer compile times, apparently, but that sounds like a linker problem?)</p>



<a name="210888699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888699">(Sep 22 2020 at 15:37)</a>:</h4>
<p>oh I see, it increases binary sizes</p>



<a name="210888704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888704">(Sep 22 2020 at 15:37)</a>:</h4>
<p>wait why do we count linker instructions? or are these LLVM instructions?</p>



<a name="210888736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888736">(Sep 22 2020 at 15:37)</a>:</h4>
<p>maybe it could be off by default in debug mode? compile times matter more there</p>



<a name="210888820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888820">(Sep 22 2020 at 15:38)</a>:</h4>
<p>well it won't help in debug mode at all anyway I don't think? except cross-crate, maybe</p>



<a name="210888841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888841">(Sep 22 2020 at 15:38)</a>:</h4>
<p>what it allows is the linker to GC unused functions</p>



<a name="210888890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888890">(Sep 22 2020 at 15:38)</a>:</h4>
<p>the problem is the only way to get this working is one section per function which I guess is where the linker or LLVM doesn't scale properly</p>



<a name="210888892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888892">(Sep 22 2020 at 15:38)</a>:</h4>
<p>there are some <em>significant</em> improvements in debug mode on perf.rlo</p>



<a name="210888962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210888962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210888962">(Sep 22 2020 at 15:39)</a>:</h4>
<p>I mean having the GC on won't help debug-mode as much, so you're right about us being able to maybe do that</p>



<a name="210889012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889012">(Sep 22 2020 at 15:39)</a>:</h4>
<p>In debug mode executable size is less important than in release mode I think.</p>



<a name="210889101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889101">(Sep 22 2020 at 15:40)</a>:</h4>
<p>what I was thinking about is when optimizations aren't enabled, LLVM isn't removing as many uses of functions</p>



<a name="210889116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889116">(Sep 22 2020 at 15:40)</a>:</h4>
<p>so it <em>also</em> is less impactful in debug mode</p>



<a name="210889125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889125">(Sep 22 2020 at 15:40)</a>:</h4>
<p>perf stat I think by default collects all child processes</p>



<a name="210889154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889154">(Sep 22 2020 at 15:40)</a>:</h4>
<p>I would gladly give up 10x the binary size for a 25% compile time decrease in debug mode</p>



<a name="210889169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889169">(Sep 22 2020 at 15:40)</a>:</h4>
<p>oh is that why it works when nesting <code>setarch</code> and whatnot huh</p>



<a name="210889209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889209">(Sep 22 2020 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> okay I feel like I'm not explaining myself properly lol</p>



<a name="210889280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889280">(Sep 22 2020 at 15:41)</a>:</h4>
<p>I got 26MB -&gt; 15MB without any optimizations when enabling per function sections in cg_clif, so even when "LLVM isn't removing as many uses of functions" it can have a big effect on executable size.</p>



<a name="210889283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889283">(Sep 22 2020 at 15:41)</a>:</h4>
<p>being able to  GC functions is a worse tradeoff for debug mode <em>on top of</em> you not caring about binary size</p>



<a name="210889303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889303">(Sep 22 2020 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> oh is that cross-crate?</p>



<a name="210889306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889306">(Sep 22 2020 at 15:41)</a>:</h4>
<p>correct, I'm saying we should <em>disable</em> <code>-ffunction-sections</code> for debug mode</p>



<a name="210889414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889414">(Sep 22 2020 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> and I'm giving you a second reason than just "I don't care about binary sizes" though it might be invalid given what <span class="user-mention" data-user-id="133247">@bjorn3</span> has measured</p>



<a name="210889447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889447">(Sep 22 2020 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> what about at <code>-C opt-level=3</code>?</p>



<a name="210889473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889473">(Sep 22 2020 at 15:43)</a>:</h4>
<p>The executable decrease in that case is probably caused by removing big chunks of unused parts of libstd.</p>



<a name="210889493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889493">(Sep 22 2020 at 15:43)</a>:</h4>
<p>that would make sense I guess</p>



<a name="210889584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889584">(Sep 22 2020 at 15:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/General/near/210889447">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> what about at <code>-C opt-level=3</code>?</p>
</blockquote>
<p>I have only measured executable sizes with cg_clif for which enabling optimizations doesn't do much at all.</p>



<a name="210889635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889635">(Sep 22 2020 at 15:44)</a>:</h4>
<p>heh</p>



<a name="210889677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889677">(Sep 22 2020 at 15:44)</a>:</h4>
<p>okay so this is mostly just cutting libstd in half or w/e</p>



<a name="210889690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889690">(Sep 22 2020 at 15:44)</a>:</h4>
<p>wait!</p>



<a name="210889715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889715">(Sep 22 2020 at 15:44)</a>:</h4>
<p>what if we compile <em>only</em> libstd with <code>-ffunction-sections</code>?</p>



<a name="210889765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889765">(Sep 22 2020 at 15:45)</a>:</h4>
<p>I can try that. Give me a minute.</p>



<a name="210889812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889812">(Sep 22 2020 at 15:45)</a>:</h4>
<p>there's also the fact that we might be doing <code>-ffunction-sections</code> on private functions</p>



<a name="210889845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889845">(Sep 22 2020 at 15:45)</a>:</h4>
<p>instead of putting private functions in their own section</p>



<a name="210889854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889854">(Sep 22 2020 at 15:45)</a>:</h4>
<p>it looks like rustc treats <code>-ffunction-sections</code> the same as <code>-fdata-sections</code> too</p>



<a name="210889918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889918">(Sep 22 2020 at 15:46)</a>:</h4>
<p>so we might get different results by enabling one but not the other</p>



<a name="210889935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889935">(Sep 22 2020 at 15:46)</a>:</h4>
<p>right we should also measure that</p>



<a name="210889986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210889986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210889986">(Sep 22 2020 at 15:46)</a>:</h4>
<p>So far I haven't tried <code>-fdata-sections</code> in cg_clif at all.</p>



<a name="210890002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890002">(Sep 22 2020 at 15:46)</a>:</h4>
<p>I was literally pressing "Edit topic" to do this and the message jumped from under me</p>



<a name="210890045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890045">(Sep 22 2020 at 15:47)</a>:</h4>
<p>anyway yeah so what I'm thinking is: we have special CGU logic for private instantiations</p>



<a name="210890073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890073">(Sep 22 2020 at 15:47)</a>:</h4>
<p>and I'm wondering if those account for most of the slowdown while offering little to no GC opportunity</p>



<a name="210890091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890091">(Sep 22 2020 at 15:47)</a>:</h4>
<p>it's also possible the linkers are just bad at this</p>



<a name="210890110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890110">(Sep 22 2020 at 15:47)</a>:</h4>
<p>have we compared <code>ld.bfd</code> vs <code>ld.gold</code> vs <code>lld</code>?</p>



<a name="210890137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890137">(Sep 22 2020 at 15:48)</a>:</h4>
<p>(I bet you each gets faster in turn)</p>



<a name="210890368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890368">(Sep 22 2020 at 15:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210889715">said</a>:</p>
<blockquote>
<p>what if we compile <em>only</em> libstd with <code>-ffunction-sections</code>?</p>
</blockquote>
<p>that would still have a compile time cost, right? because we call the linker on libstd every time rustc runs?</p>



<a name="210890369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890369">(Sep 22 2020 at 15:49)</a>:</h4>
<p>I only tried the default linker. <code>lld</code> is a bit picky about what it accepts. In fact I found this optimization opportunity after noticing that cg_llvm used <code>-ffunction-sections</code> when I was trying to fix cg_clif to work with <code>lld</code>.</p>



<a name="210890453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890453">(Sep 22 2020 at 15:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210890368">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210889715">said</a>:</p>
<blockquote>
<p>what if we compile <em>only</em> libstd with <code>-ffunction-sections</code>?</p>
</blockquote>
<p>that would still have a compile time cost, right? because we call the linker on libstd every time rustc runs?</p>
</blockquote>
<p>I want us to validate that tbh</p>



<a name="210890454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890454">(Sep 22 2020 at 15:50)</a>:</h4>
<p>Gotta rewrite all the linkers in Rust, obvi.</p>



<a name="210890467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890467">(Sep 22 2020 at 15:50)</a>:</h4>
<p>because we don't actually know what's going on</p>



<a name="210890495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890495">(Sep 22 2020 at 15:50)</a>:</h4>
<p>sure, more data is always good</p>



<a name="210890499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890499">(Sep 22 2020 at 15:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> gimme that fully parallelized linking</p>



<a name="210890564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890564">(Sep 22 2020 at 15:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210889715">said</a>:</p>
<blockquote>
<p>what if we compile <em>only</em> libstd with <code>-ffunction-sections</code>?</p>
</blockquote>
<p>23MB executable, ~0.55s linker time</p>



<a name="210890622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890622">(Sep 22 2020 at 15:51)</a>:</h4>
<p>huh</p>



<a name="210890668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890668">(Sep 22 2020 at 15:51)</a>:</h4>
<p>is it libstd or libcore that actually has most of the unused MBs?</p>



<a name="210890672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890672">(Sep 22 2020 at 15:51)</a>:</h4>
<p>For comparison these are the results for cg_llvm and cg_clif with and without everything <code>-ffunction-sections</code>: <a href="https://github.com/bjorn3/rustc_codegen_cranelift/issues/762#issuecomment-696690733">https://github.com/bjorn3/rustc_codegen_cranelift/issues/762#issuecomment-696690733</a></p>



<a name="210890794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210890794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210890794">(Sep 22 2020 at 15:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210890668">said</a>:</p>
<blockquote>
<p>is it libstd or libcore that actually has most of the unused MBs?</p>
</blockquote>
<p>How do I measure that?</p>



<a name="210891441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891441">(Sep 22 2020 at 15:57)</a>:</h4>
<p>uhhh</p>



<a name="210891470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891470">(Sep 22 2020 at 15:57)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> do what you did for libstd but for libcore instead?</p>



<a name="210891489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891489">(Sep 22 2020 at 15:57)</a>:</h4>
<p>compile a program with <code>#![no_std]</code>?</p>



<a name="210891509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891509">(Sep 22 2020 at 15:57)</a>:</h4>
<p>assuming you limited to literally only <code>library/std</code> and not the entirety of <code>library/</code></p>



<a name="210891515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891515">(Sep 22 2020 at 15:57)</a>:</h4>
<p>and also <code>#![no_core]</code> for sanity maybe</p>



<a name="210891602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891602">(Sep 22 2020 at 15:58)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I mean at that point you can just measure <code>libcore.rlib</code>'s size</p>



<a name="210891608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891608">(Sep 22 2020 at 15:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210891509">said</a>:</p>
<blockquote>
<p>assuming you limited to literally only <code>library/std</code> and not the entirety of <code>library/</code></p>
</blockquote>
<p>I used it for all of <code>library/</code>.</p>



<a name="210891620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891620">(Sep 22 2020 at 15:58)</a>:</h4>
<p>ah wow what</p>



<a name="210891670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891670">(Sep 22 2020 at 15:58)</a>:</h4>
<p>and that only resulted in a 3MB reduction?</p>



<a name="210891690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891690">(Sep 22 2020 at 15:58)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> is it still set to GC sections?</p>



<a name="210891732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891732">(Sep 22 2020 at 15:59)</a>:</h4>
<p>even if it doesn't use <code>-ffunction-sections</code> for later crates?</p>



<a name="210891746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891746">(Sep 22 2020 at 15:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210891602">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> I mean at that point you can just measure <code>libcore.rlib</code>'s size</p>
</blockquote>
<p>rlibs are not created using the linker.</p>



<a name="210891816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891816">(Sep 22 2020 at 15:59)</a>:</h4>
<p>I mean the size of an un-GC'd executable is going to be roughly the size of all the <code>.o</code> files in dependencies' <code>rlib</code>s, added together</p>



<a name="210891830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891830">(Sep 22 2020 at 15:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/-ffunction-sections/near/210891732">said</a>:</p>
<blockquote>
<p>even if it doesn't use <code>-ffunction-sections</code> for later crates?</p>
</blockquote>
<p>I only changed the object write code of cg_clif. I didn't change the linker code, so <code>--gc-sections</code> is still passed.</p>



<a name="210891918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210891918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210891918">(Sep 22 2020 at 16:00)</a>:</h4>
<p>they're almost entirely concatenated (well, the contents of sections are)</p>



<a name="210892097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892097">(Sep 22 2020 at 16:01)</a>:</h4>
<p>I have disabled <code>--gc-sections</code> for none of the measurements. The only variable was what object files used per function sections and which used a single <code>.text</code> section.</p>



<a name="210892258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892258">(Sep 22 2020 at 16:02)</a>:</h4>
<p>mkay. I'm not sure exactly how to measure where  the reduction all the way down to 15MB is coming from</p>



<a name="210892328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892328">(Sep 22 2020 at 16:02)</a>:</h4>
<p>I guess you could use <code>-ffunction-sections</code> and compare the list of symbols between <code>--gc-sections</code> on and off (or the list of sections?)</p>



<a name="210892439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892439">(Sep 22 2020 at 16:03)</a>:</h4>
<p>I will try that.</p>



<a name="210892494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892494">(Sep 22 2020 at 16:03)</a>:</h4>
<p>you might want to use <code>-Z symbol-mangling-version=v0</code> because it includes the instantiating crate for generics/<code>#[inline]</code></p>



<a name="210892559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892559">(Sep 22 2020 at 16:04)</a>:</h4>
<p>at least I think it should in relevant cases</p>



<a name="210892571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892571">(Sep 22 2020 at 16:04)</a>:</h4>
<p>LLD can use multiple threads for some of the operations. I imagine it would regress instructions but improve real time.</p>



<a name="210892594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892594">(Sep 22 2020 at 16:04)</a>:</h4>
<p>(whereas the legacy mangling just hashes it in)</p>



<a name="210892697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892697">(Sep 22 2020 at 16:05)</a>:</h4>
<p>Longer symbol names lead to worse linker times. I had to hash some of the symbols I produced for better linker times.</p>



<a name="210892835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210892835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210892835">(Sep 22 2020 at 16:06)</a>:</h4>
<p>that reminds me we should have a mode for that lol, I keep forgetting that's a problem</p>



<a name="210893562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210893562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210893562">(Sep 22 2020 at 16:11)</a>:</h4>
<p>26788 functions are GC'ed<br>
of these<br>
7891 start with _ZN4core<br>
1796 start with _ZN5alloc<br>
1528 start with _ZN3std</p>



<a name="210893625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210893625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210893625">(Sep 22 2020 at 16:11)</a>:</h4>
<p>trait implementations are not included in the core, alloc and std numbers.</p>



<a name="210893891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210893891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210893891">(Sep 22 2020 at 16:13)</a>:</h4>
<p>for the trait implementations<br>
4860 contain "core.."<br>
1051 contain "alloc.."<br>
830 contain "std.."<br>
this included trait implementations of traits in those crates by other crates</p>



<a name="210894071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210894071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210894071">(Sep 22 2020 at 16:14)</a>:</h4>
<p>(I used <code>diff &lt;(objdump -t ./raytracer_cg_clif | cut -c62- ) &lt;(objdump -t target/debug/main | cut -c62- ) | grep "&lt;" | cut -c3- | sort | ...</code> as diff command. <code>./raytracer_cg_clif</code> doesn't use <code>-ffunction-sections</code>, <code>target/debug/main</code> does)</p>



<a name="210894293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210894293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210894293">(Sep 22 2020 at 16:16)</a>:</h4>
<p>Can I mix enabling and disabling <code>-Z symbol-mangling-version=v0</code>? Edit: never mind. I just recompiled everything.</p>



<a name="210897668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210897668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210897668">(Sep 22 2020 at 16:40)</a>:</h4>
<p>you can mix it but it's gonna be less useful</p>



<a name="210897731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210897731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210897731">(Sep 22 2020 at 16:41)</a>:</h4>
<p>(the value of the flag from the "defining crate" is used, in order for linking to succeed no matter how you combine them)</p>



<a name="210899027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210899027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210899027">(Sep 22 2020 at 16:51)</a>:</h4>
<p>Here is the full diff produced using <code>diff &lt;(objdump -t ./raytracer_cg_clif_mangle_v0 | cut -c62- ) &lt;(objdump -t target/debug/main | cut -c62- ) | grep "&lt;" | cut -c3- | grep -v "\.o" | sed "s/\.hidden //" | sed "s/^ *//" | sort</code>: <a href="https://gist.github.com/bjorn3/d65282d3b32894e62ecc7ea071b2e368">https://gist.github.com/bjorn3/d65282d3b32894e62ecc7ea071b2e368</a></p>



<a name="210899982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210899982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210899982">(Sep 22 2020 at 16:58)</a>:</h4>
<p>heh all the <code>__alloc_...</code>, are those miri allocs? cc <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="210901649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210901649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210901649">(Sep 22 2020 at 17:11)</a>:</h4>
<p>Yes, that is how cg_clif represents miri allocs that are not statics. The number after <code>__alloc_</code> is identical to the <code>AllocId</code>.</p>



<a name="210903778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210903778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210903778">(Sep 22 2020 at 17:25)</a>:</h4>
<p>I wonder what LLVM unnamed globals turn into. maybe just no symbols?</p>



<a name="210904665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210904665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210904665">(Sep 22 2020 at 17:32)</a>:</h4>
<p>LLVM uses <code>str.0</code>, <code>str.1</code>, ... for that I think. At least those are part of a random executable I tested.</p>



<a name="210910381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210910381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210910381">(Sep 22 2020 at 18:13)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> did you try string literals, or other things? it's a private label here <a href="https://godbolt.org/z/qzaocr">https://godbolt.org/z/qzaocr</a></p>



<a name="210910494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210910494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210910494">(Sep 22 2020 at 18:14)</a>:</h4>
<p>with all the filters disabled: <a href="https://godbolt.org/z/h7ov6x">https://godbolt.org/z/h7ov6x</a></p>



<a name="210911767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210911767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210911767">(Sep 22 2020 at 18:24)</a>:</h4>
<p>I just picked a random executable. Private labels are not supported by object, so I can't use them in cg_clif.</p>



<a name="210911802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210911802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210911802">(Sep 22 2020 at 18:24)</a>:</h4>
<p>I mean, they're an assembler abstraction, aren't they?</p>



<a name="210911829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210911829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210911829">(Sep 22 2020 at 18:24)</a>:</h4>
<p>you just put data into a section and refer to its offset relative to the object, no?</p>



<a name="210912894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210912894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210912894">(Sep 22 2020 at 18:33)</a>:</h4>
<p>cranelift-object doesn't allow that. it basically has define/declare_func/data combined with a few methods for interoperability with cranelift-codegen.</p>



<a name="210913058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210913058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210913058">(Sep 22 2020 at 18:34)</a>:</h4>
<p>cranelift-object and cranelift-simplejit have the exact same exposed api surface before finalizing. after finalizing you can't add new functions generated by cranelift anymore without basically duplicating them.</p>



<a name="210914753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210914753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210914753">(Sep 22 2020 at 18:49)</a>:</h4>
<p>Created <a href="https://github.com/bytecodealliance/wasmtime/issues/2220">https://github.com/bytecodealliance/wasmtime/issues/2220</a></p>



<a name="210935043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210935043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210935043">(Sep 22 2020 at 21:43)</a>:</h4>
<p>FWIW, using function sections only for std in debug sounds great.</p>



<a name="210935074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210935074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210935074">(Sep 22 2020 at 21:43)</a>:</h4>
<p>That would allow throwing away unused parts of std.</p>



<a name="210958497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210958497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210958497">(Sep 23 2020 at 04:30)</a>:</h4>
<p>"only for std in debug", but not in release?</p>



<a name="210958506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210958506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210958506">(Sep 23 2020 at 04:30)</a>:</h4>
<p>I meant always using it for std, but in debug not using it for anything else.</p>



<a name="210959437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210959437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210959437">(Sep 23 2020 at 04:57)</a>:</h4>
<p>would that be determined by a particular profile flag or just the literal names of the profiles?</p>



<a name="210967421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210967421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210967421">(Sep 23 2020 at 07:33)</a>:</h4>
<p>Using it only for std is almost as bad as always using it. ~0.55s when using -ffunction-sections for the sysroot only.  ~0.6s when using -ffunction-sections for everything. ~0.4s when never using -ffunction-sections.</p>



<a name="210970975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210970975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210970975">(Sep 23 2020 at 08:13)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> are you measuring the LLVM backend's output or the cranelift backend? is there any chance there's a difference between the two?</p>



<a name="210971126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210971126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210971126">(Sep 23 2020 at 08:15)</a>:</h4>
<p>I have been measuring cg_clif. There could be a difference between the two. At least for cg_clif there is no -fdata-sections support yet, while cg_llvm enables/disables -ffunction-sections and -fdata-sections at the same time.</p>



<a name="210971783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210971783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210971783">(Sep 23 2020 at 08:23)</a>:</h4>
<p>c113030 is the parent. 8a4aabc is my commit.</p>
<div class="codehilite"><pre><span></span><code>-rwxr-xr-x 1 bjorn bjorn 7819000 sep 22 10:52 /home/bjorn/.rustup/toolchains/c113030f6b7d10cd27ac7091718e6f48ecf56a63/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-edfba68bd3501617.so
-rwxr-xr-x 1 bjorn bjorn 7712688 sep 22 14:30 /home/bjorn/.rustup/toolchains/8a4aabcca5f2e9187df7a96c20f8cba616c0be39/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-edfba68bd3501617.so
</code></pre></div>


<p><a href="http://libstd.so">libstd.so</a> got a bit smaller without -ffunction-sections for cg_llvm.</p>



<a name="210971904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210971904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210971904">(Sep 23 2020 at 08:24)</a>:</h4>
<p>I think because <code>--gc-sections</code> can't remove anything and sections have a bit of size overhead.</p>



<a name="210972524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210972524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210972524">(Sep 23 2020 at 08:31)</a>:</h4>
<p>Here are the full cg_llvm results for the benchmark I used with cg_clif in my previous messages:</p>
<div class="codehilite"><pre><span></span><code>$ git remote get-url origin
https://github.com/ebobby/simple-raytracer
$ git rev-parse HEAD
804a7a21b9e673a482797aa289a18ed480e4d813
</code></pre></div>


<h1><a href="https://github.com/rust-lang/rust/commit/c113030f6b7d10cd27ac7091718e6f48ecf56a63">c113030f6b7d10cd27ac7091718e6f48ecf56a63</a> (before my PR)</h1>
<div class="codehilite"><pre><span></span><code>$ du -s target/debug/deps
108832  target/debug/deps
$ du -s target/debug/main
14692   target/debug/main
$ for i in $(seq 0 10); do rm target/debug/deps/main-*; RUSTFLAGS=&quot;-Ztime-passes&quot; cargo +c113030f6b7d10cd27ac7091718e6f48ecf56a63 build |&amp; grep run_linker; done
time: 0.735; rss: 127MB run_linker
time: 0.731; rss: 126MB run_linker
time: 0.729; rss: 126MB run_linker
time: 0.739; rss: 128MB run_linker
time: 0.729; rss: 127MB run_linker
time: 0.724; rss: 126MB run_linker
time: 0.726; rss: 128MB run_linker
time: 0.725; rss: 127MB run_linker
time: 0.738; rss: 127MB run_linker
time: 0.736; rss: 128MB run_linker
time: 0.732; rss: 126MB run_linker
</code></pre></div>


<h1><a href="https://github.com/rust-lang/rust/commit/8a4aabcca5f2e9187df7a96c20f8cba616c0be39">8a4aabcca5f2e9187df7a96c20f8cba616c0be39</a> (after my PR)</h1>
<div class="codehilite"><pre><span></span><code>$ du -s target/debug/deps
104800  target/debug/deps
$ du -s target/debug/main
20552   target/debug/main
$ for i in $(seq 0 10); do rm target/debug/deps/main-*; RUSTFLAGS=&quot;-Ztime-passes&quot; cargo +8a4aabcca5f2e9187df7a96c20f8cba616c0be39 build |&amp; grep run_linker; done
time: 0.457; rss: 126MB run_linker
time: 0.454; rss: 126MB run_linker
time: 0.457; rss: 127MB run_linker
time: 0.452; rss: 127MB run_linker
time: 0.457; rss: 126MB run_linker
time: 0.454; rss: 126MB run_linker
time: 0.460; rss: 126MB run_linker
time: 0.457; rss: 125MB run_linker
time: 0.455; rss: 127MB run_linker
time: 0.472; rss: 126MB run_linker
time: 0.459; rss: 127MB run_linker
</code></pre></div>



<a name="210972551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210972551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210972551">(Sep 23 2020 at 08:31)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> ^</p>



<a name="210972667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210972667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210972667">(Sep 23 2020 at 08:32)</a>:</h4>
<p>hmm 20MB is better than 26MB</p>



<a name="210972717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210972717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210972717">(Sep 23 2020 at 08:33)</a>:</h4>
<p>oh but we should compare relatively, since cranelift doesn't have the same machine code output d'oh</p>



<a name="210972886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210972886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210972886">(Sep 23 2020 at 08:34)</a>:</h4>
<p>cg_llvm uses a release build sysroot even during a debug build. cg_clif also uses a "release" build sysroot, but cg_clif doesn't perform inlining and things like that.</p>



<a name="210981870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210981870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210981870">(Sep 23 2020 at 10:04)</a>:</h4>
<p>To come back to what symbols are gced. 14372 symbols start with <code>_RN</code>. Of those 4300 come from core, alloc or std.</p>



<a name="210981969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210981969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210981969">(Sep 23 2020 at 10:05)</a>:</h4>
<p>I made a jupyter notebook using evcxr for the analysis of which symbols are gced.</p>



<a name="210983160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210983160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210983160">(Sep 23 2020 at 10:17)</a>:</h4>
<p>Exact symbol origin numbers:</p>
<div class="codehilite"><pre><span></span><code>core: 1257
alloc: 341
std: 3042
</code></pre></div>



<a name="210986488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/210986488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#210986488">(Sep 23 2020 at 11:00)</a>:</h4>
<p><a href="https://gist.github.com/bjorn3/df27609cd6193a2545c5460027afa0bd">https://gist.github.com/bjorn3/df27609cd6193a2545c5460027afa0bd</a></p>



<a name="211734830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211734830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211734830">(Sep 30 2020 at 09:27)</a>:</h4>
<p>I have pushed a new version that disables <code>--gc-sections</code> instead of <code>-ffunction-sections</code>. This can be done in debug mode without hurting release mode sizes, while hopefully preserving most of the link time benefit.</p>



<a name="211800885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211800885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211800885">(Sep 30 2020 at 18:25)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Nice. And that seems like something that could potentially be turned back on with an option.</p>



<a name="211801819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211801819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211801819">(Sep 30 2020 at 18:33)</a>:</h4>
<p>(perf results <a href="https://perf.rust-lang.org/compare.html?start=511ed9f2356af365ad8affe046b3dd33f7ac3c98&amp;end=62ede63726a44d18001f60e2a93b55965b9ca2d8">are in</a>)</p>



<a name="211802042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211802042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211802042">(Sep 30 2020 at 18:34)</a>:</h4>
<p>They are, but they don't look good. :(</p>



<a name="211802197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211802197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211802197">(Sep 30 2020 at 18:36)</a>:</h4>
<p>a bit surprising</p>



<a name="211802542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211802542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211802542">(Sep 30 2020 at 18:39)</a>:</h4>
<p>I could also try to not use <code>-ffunction-sections</code> only in debug mode. That won't give as much savings as also compiling the sysroot without <code>-ffunction-sections</code> but it should be shippable.</p>



<a name="211802772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211802772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211802772">(Sep 30 2020 at 18:40)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> I'd love to see the numbers on that.</p>



<a name="211805213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211805213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211805213">(Sep 30 2020 at 19:00)</a>:</h4>
<p>I seem to remember you already tried that in some of your local tests, right ?</p>



<a name="211805650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211805650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211805650">(Sep 30 2020 at 19:04)</a>:</h4>
<p>Yes, the conclusion was still an improvement, just less that when building everything without -ffunction-sections.</p>



<a name="211805709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211805709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211805709">(Sep 30 2020 at 19:05)</a>:</h4>
<p>I pushed a new version to only use -ffunction-sections when the opt level is not 0. Can I get a new perf run?</p>



<a name="211805734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/-ffunction-sections/near/211805734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/-ffunction-sections.html#211805734">(Sep 30 2020 at 19:05)</a>:</h4>
<p>done</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>